﻿using System;
using System.Collections.Generic;
using System.Text;

namespace AD.Pms.Core.Extension
{
    public static class IEnumerableExtension
    {
        public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue, T>(IEnumerable<T> list, Func<T, TKey> keySelector, Func<T, TValue> valueSelector)
        {
            Dictionary<TKey, TValue> dict = new Dictionary<TKey, TValue>();
            foreach (var item in list)
            {
                var key = keySelector(item);
                var value = valueSelector(item);
                dict[key] = value;
            }
            return dict;
        }
    }
}
